<script type="text/javascript">
function addRewriteRule(){ //增加
  $('#rewrite-rule-form').append($('#rewrite-rule-tpl').html());
}
function removeRewriteRule(e){
  $(e).closest('tr').remove();
}
</script>
<div class="bw-row pad10 cut">
  <form method="post" action="<{url m=$MOD c='setting' a='update' step='rewrite'}>">
    <table class="dataform">
      <tr>
        <th width="120">URL 伪静态</th>
        <td>
          <div class="pad5">
            <label><input type="radio" name="rewrite_enable" value="1" <{if $rs.rewrite_enable == 1}>checked="checked"<{/if}> /><font class="green ml5">开启</font></label>
            <label class="ml20"><input type="radio" name="rewrite_enable" value="0" <{if $rs.rewrite_enable == 0}>checked="checked"<{/if}> /><font class="red ml5">关闭</font></label>
            <font class="ml20 vtcmid caaa">开启URL 伪静态(URL Rewrite)，请确认您的服务器或空间支持URL Rewrite功能</font>
          </div>
        </td>
      </tr>
      <tr>
        <th>伪静态规则</th>
        <td>
          <div class="module">
            <button type="button" class="cbtn sm btn" onclick="addRewriteRule()">+1 规则</button>
            <font class="ml20 vtcmid caaa">设置伪静态规则，只有在系统开启了URL Rewrite功能后才会生效</font>
          </div>
          <div class="module mt8">
            <table class="dataform" id="rewrite-rule-form">
	      <tr>
                <td width="35"><button type="button" class="mbtn btn disabled" disabled="disabled">移除</button></td>
                <td><input class="w200 txt ta-r disabled" name="rewrite_rule[k][]" value="pay/notify/<pcode>" readonly="readonly" /><span class="sep20 c999">===</span><input class="w200 txt disabled" name="rewrite_rule[v][]" value="pay/notify" readonly="readonly" /></td>
              </tr>
	      <tr>
                <td><button type="button" class="mbtn btn disabled" disabled="disabled">移除</button></td>
                <td><input class="w200 txt ta-r disabled" name="rewrite_rule[k][]" value="pay/return/<pcode>" readonly="readonly" /><span class="sep20 c999">===</span><input class="w200 txt disabled" name="rewrite_rule[v][]" value="pay/return" readonly="readonly" /></td>
              </tr>
              <{foreach $rs.rewrite_rule as $k => $v}>
              <tr>
                <td><button type="button" class="mbtn btn" onclick="removeRewriteRule(this)">移除</button></td>
                <td><input class="w200 txt ta-r" name="rewrite_rule[k][]" value="<{$k}>" /><span class="sep20 c999">===</span><input class="w200 txt" name="rewrite_rule[v][]" value="<{$v}>" /></td>
              </tr>
              <{/foreach}>
            </table>
          </div>
        </td>
      </tr>
    </table>
    <div class="submitbtn" style="padding-left:260px;">
      <button type="submit" class="ubtn btn">保存并更新伪静态设置</button>
      <button type="reset" class="fbtn btn">重置表单</button>
    </div>
  </form>
</div>
<script type="text/template" id="rewrite-rule-tpl">
<tr>
  <td width="35"><button type="button" class="mbtn btn" onclick="removeRewriteRule(this)">移除</button></td>
  <td><input class="w200 txt ta-r" name="rewrite_rule[k][]" value="" /><span class="sep20 c999">===</span><input class="w200 txt" name="rewrite_rule[v][]" value="" /></td>
</tr>
</script>